<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name:'培训费'}"></three-title>
    <div class="layerRtb-scroll thinScroll" v-scrollHeight = "137">
        <div class="analyItem">
            <p class="analyItemTit tx-center" title="">培训费</p>
            <div class="analyItemCon">
                <p>
                    <span class="cLightGray pr8 fl">金额</span>
                    <input type="text" v-model="money" class=" fl" id="trainmoney">
                    <input type="button" id="savetrainmoney" value="确定" class="uiBtn-blue uiBtn-normal fl ml10">
                </p>
            </div>
        </div>
    </div>
    <div class="layerRtb-footer">
        <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
                <p class="fl col-md-4">
                    <span class="cLightGray">已付金额</span>
                    <span class="cGreen fz14 bold">0</span>
                </p>
                <p class="fr col-md-4">
                    <span class="cLightGray">未付金额</span>
                    <span class="cGreen fz14 bold">0</span>
                </p>
            </div>
        </div>
    </div>
</div>
</template>
<script>
import {
    mapGetters
} from 'vuex'
import {
    saveTrainMoney, savePmUserTrainMoney
} from '../../Resources/Api'
export default {
    data () {
        return {
            money: 0
        }
    },
    created () {

    },
    methods: {
        saveTrainMoney () {
            saveTrainMoney({
                DivisionId: 4, // 师ID
                CorpsID: 21, // 团ID
                Subject: 509, // 项目经理培训费
                Summary: this.leftInfo.user_name + '本次应缴纳培训费' + this.money,
                ShouldAmount: this.money,
                SourceBy: this.leftInfo.user_name,
                Money: this.money,
                CompanyName: this.leftInfo.dq_name,
                CompanyCode: '-',
                CompanyID: this.leftInfo.uid,
                Region: this.leftInfo.dq_name,
                Province: '-',
                Level: '-'
            }).then(result => {
                if (result.data.statusCode === 1) {
                    this.savePmUserTrainMoney(result.data.statuMsg)
                } else {
                    this.$message('保存成功')
                }
            }).catch(err => {
                console.log(err)
            })
        },
        savePmUserTrainMoney (value) {
            savePmUserTrainMoney({
                UId: this.leftInfo.uid,
                UserName: this.leftInfo.user_name,
                Money: this.money,
                Remark: this.leftInfo.user_name + '本次应缴纳培训费' + this.money,
                SourceCode: value
            }).then(result => {
                this.$message('保存失败')
            }).catch(err => {
                console.error(err)
            })
        }
    },
    computed: {
        ...mapGetters(['leftInfo'])
    }
}
</script>
